#ifndef __SCENE_OBJECT_H_
#define __SCENE_OBJECT_H_

#include <map>
#include <string>
#include <vector>
#include <tr1/memory>
#include "model/cube.h"
#include "model/objectModel/objectModel.h"

class SceneObject{
	public:
		typedef std::tr1::shared_ptr<ObjectModel> ObjectModelPtr;
	protected:
		std::map<std::string,SceneObject*> listObject;
		SceneObject* parent;
		ObjectModelPtr objectModel;
		Cube dimensions;
		Point speed;
		Point direction;

	public:
		SceneObject();
		SceneObject(const ObjectModelPtr& model);
		SceneObject(const Cube& cube);
		SceneObject(const Cube& cube,const ObjectModelPtr& model);
		SceneObject(const Point& direction);
		SceneObject(const Point& direction,const ObjectModelPtr& model);
		SceneObject(const Cube& cube,const Point& direction);
		SceneObject(const Cube& cube,const Point& direction,const ObjectModelPtr& model);
		virtual ~SceneObject();

		virtual void addObject(const std::string& name,SceneObject* obj);
		void removeObject(const std::string& name);
		SceneObject& findObject(const std::string& name)const;
		SceneObject* getObject(const std::string& name);

		std::map<std::string,SceneObject*>::const_iterator beginObjects(){ return this->listObject.begin(); }
		std::map<std::string,SceneObject*>::const_iterator endObjects(){ return this->listObject.end(); }

		virtual void setSpeed(const Point& sp){this->speed=sp;}
		const Point& getSpeed(){ return this->speed;}

		virtual void setEnv(){}
		virtual void unsetEnv(){}
		virtual void setModelMatrix();
		virtual void setSubModelMatrix(const std::string& name="");

		void setDimensions(const Cube& cube){ this->dimensions = cube; }
		Cube& getDimensions(){ return dimensions;}

		const Point& getDirection(){ return direction; }
		virtual void setDirection(const Point& point);

		ObjectModel& getObjectModel(){ return *this->objectModel; }
		virtual void setObjectModel(const ObjectModelPtr& model){ this->objectModel=model; }

		void setParent(SceneObject* obj){ this->parent=obj; }
		SceneObject& getParent(){ return *this->parent; }
		bool hasParent(){ return this->parent!=NULL; }

		virtual void move(float dx,float dy,float dz){
			this->dimensions.translate(dx,dy,dz);
		}

		virtual void rotate (float angle){}

		virtual void timeStep(){}
};


#endif //__SCENE_OBJECT_H_
